<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
	<head>
		<jsp:include page="../inc.jsp"></jsp:include>
		<script type="text/javascript" charset="utf-8">
	var datagrid;
	var tyid = "${sessionInfo.type}";
	$(function() {
		$('form input').bind('keyup', function(event) {/* 增加回车提交功能 */
			if (event.keyCode == '13') {
				_search();
			}
		});
		datagrid = $('#datagrid').datagrid({
			url : 'goodsAmountAction!datagrid.html',
			title : '库存列表',
			iconCls : 'icon-save',
			pagination : true,
			pagePosition : 'bottom',
			pageSize : 10,
			pageList : [ 10, 20, 30, 40 ],
			fit : true,
			fitColumns : false,
			nowrap : false,
			border : false,
			idField : 'id',
			sortName : 'name',
			sortOrder : 'desc',
			checkOnSelect : false,
			selectOnCheck : false,
			singleSelect : true,
			frozenColumns : [ [  {
				title : '商品条码',
				field : 'barcode',
				width : 120,
				sortable : true,
			} , {
				title : '款号',
				field : 'type',
				width : 80,
				sortable : true,
			}]],
			columns : [ [  {
				title : '商品名称',
				field : 'name',
				width : 100,
				sortable : true,
			}, {
				title : '品牌',
				field : 'bname',
				width : 70
			}, {
				title : '品牌ID',
				field : 'bid',
				width : 50,
				hidden : true
			}, {
				title : '颜色',
				field : 'color',
				width : 50,
				align:'center'
			}, {
				title : '尺码',
				field : 'size',
				width : 50,
				align:'center',
				sortable : true,
			},{
				title : '单位',
				field : 'unit',
				width : 40,
				align:'center'
			},{
				title : '吊牌价',
				field : 'showPrice',
				width : 50,
				align:'center',
				sortable : true,
			} ,{
				title : '售价',
				field : 'salePrice',
				width : 50,
				align:'center',
				sortable : true,
			}
			,{
				title : '成本价',
				field : 'buyPrice',
				width : 60,
				align:'center',
				sortable : true,
			}, {
				title : '总金额',
				field : 'total',
				width : 70,
				align:'center',
				sortable : true,
			}, {
				title : '库存总数',
				field : 'amount',
				width : 60,
				align:'center',
				sortable : true,
			}, {
				title : '所属仓库ID',
				field : 'rid',
				width : 50,
				hidden : true
			}, {
				title : '仓库名称',
				field : 'rname',
				width : 80
			}] ]
		});
		if(tyid==5||tyid==1){
			$('#datagrid').datagrid('showColumn','buyPrice')
		}else{
			$("#cb").hide();
			$('#datagrid').datagrid('hideColumn','buyPrice')
		}
		_search();
		
		/*$('#memberForm').form('submit', {
			url : '${pageContext.request.contextPath}/hygl/memberAction!add.html',
			type : "POST",
			success : function(d) {
				closeDiv();
				var json = $.parseJSON(d);
				$('#mMobile').val(json.obj.mobile);
				$('#mid').val(json.obj.id);
				$('#mtid').val(json.obj.tid);
				$('#point').val(json.obj.point);
				
				$('#consumePoint').html('');
				for(var i = 0;i*pointDeductionBase<=Number(json.obj.point);i++){
					$('#consumePoint').append('<option value="'+i*pointDeductionBase+'">'+i*pointDeductionBase+'</option>');
				}
				sy.messagerAlert('新增会员成功', '您新增的会员信息如下：<br/><br/>会员编号：'+json.obj.serial+'<br/>会员姓名：'+json.obj.name+'<br/>会员生日: '+json.obj.birthdayA+'<br/>初始积分：'+(json.obj.point?json.obj.point:'0')+'<br/>会员地址：'+(json.obj.address?json.obj.address:''), 'info');							
			}
		});*/
					
		var bid0 = $('#searchForm').find('input[name=bid]');
		var bid0Combobox = bid0.combobox({
			url : '${pageContext.request.contextPath}/spgl/brandAction!noAuth_combobox.html',
			valueField : 'id',
			textField : 'name',
			multiple : false,
			editable : false,
			onLoadSuccess : function() {
				parent.$.messager.progress('close');
			}
		});
		
		var rid0 = $('#searchForm').find('input[name=rid]');
		var rid0Combobox = rid0.combobox({
			url : '${pageContext.request.contextPath}/rkgl/repertoryAction!noAuth_combobox2.html',
			valueField : 'id',
			textField : 'name',
			multiple : false,
			editable : false,
			onLoadSuccess : function() {
// 			var sa = '${sessionInfo.repertoryIds}';
// 				if(sa!='null'&&sa!='undefinded'&&sa!=null){ 
// 				   rid0.combobox('setValue','${sessionInfo.repertoryIds}');
// 				}
				parent.$.messager.progress('close');
			}
		});
		
	});


	function _search() {
		datagrid.datagrid('load', sy.serializeObject($('#searchForm')));
		$('#searchForm').form('submit', {
			url : '${pageContext.request.contextPath}/kcgl/goodsAmountAction!datagridTotal.html',
			type : "POST",
			success : function(d){
				var json = $.parseJSON(d);
				$('#zrks').html(json.zrks);
				$('#zcks').html(json.zcks);
				$('#zkc').html(json.zkc);
				$('#kczje').html((json.kczje).toFixed(2));
				$('#cbzje').html((json.cbzje).toFixed(2));
				$('#dpzje').html((json.dpzje).toFixed(2));
			}
		});
	}
	
	function cleanSearch() {
		datagrid.datagrid('load', {});
		$('#searchForm input').val('');
		_search();
	}
</script>
	</head>
	<body class="easyui-layout" data-options="fit:true">
		<div data-options="region:'north',border:false,title:'搜索条件'"
			style="height: 112px; overflow: hidden;">
			<form id="searchForm" method="post">
				<table class="tableForm datagrid-toolbar"
					style="width: 100%; height: 100%;">
					<tr>
						<th style="width: 80px;">商品条码</th>
						<td style="width: 200px;"><input name="barcode" style="width: 200px;" /></td>
						<th style="width: 80px;">款&nbsp;&nbsp;&nbsp;&nbsp;号</th>
						<td style="width: 200px;"><input name="type" style="width: 200px;" /></td>
						<th style="width: 80px;">颜色</th>
						<td style="width: 200px;"><input name="color" style="width: 200px;" /></td>
					</tr>
					<tr>
						<th>尺&nbsp;&nbsp;&nbsp;&nbsp;码</th>
						<td><input name="size" style="width: 200px;" /></td>
						<th>所属仓库</th>
						<td><input name="rid" style="width: 200px;" /></td>
						<th>品牌</th>
						<td><input name="bid" style="width: 200px;" /></td>
					</tr>
					<tr>
						<td colspan="6" align="right" style="text-align:center">
							<a href="javascript:void(0);" class="easyui-linkbutton"
								onclick="_search();">搜索</a><a href="javascript:void(0);"
								class="easyui-linkbutton" onclick="cleanSearch();">取消</a>
						</td>
					</tr>
				</table>
			</form>
		</div>
		
		<div data-options="region:'center',border:false"
			style="overflow: hidden;">
			<table id="datagrid"></table>
		</div>
		<div data-options="region:'south',border:false"
		align="right" 	style="background:#F2F2F2; height: 25px">
				总入库数:<span  id="zrks"></span>&nbsp;&nbsp;	
				总出库数:<span id="zcks"></span>	&nbsp;&nbsp;
				总库存:<span id="zkc"></span>&nbsp;&nbsp;	
				吊牌价总金额:<span id="dpzje" ></span>&nbsp;
				 库存总金额:<span id="kczje" ></span>&nbsp;&nbsp;
				 <span id="cb">
				成本总金额:<span id="cbzje" ></span>&nbsp;
				</span>
		
		</div>
	</body>
</html>